﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestMods.Building_Blocks
{
    sealed class Case : IEquatable<Case>
    {
        public int age { get; set; }

        public string className { get; set; }

        public double duration { get; set; }

        public string errorDetails { get; set; }

        public string errorStackTrace { get; set; }

        public int failedSince { get; set; }

        public string name { get; set; }

        public bool skipped { get; set; }

        public string status { get; set; }

        public string stderr { get; set; }

        public string stdout { get; set; }

        public string RegexWithStableCategory { get { return @"[^\{\}]*?Category\(.Stable.\)[^\{\}]*?" + name + @"\("; } }

        public string RegexWithUnstableCategory { get { return @"[^\{\}]*?Category\(.Unstable.\)[^\{\}]*?" + name + @"\("; } }

        public string RegexWithoutCategory { get { return @"[^\{\}]*?" + name + @"\("; } }

        public bool Equals(Case other)
        {
            if (ReferenceEquals(other, null)) { return false; }

            return name.Equals(other.name) && className.Equals(other.className);
        }

        public override int GetHashCode()
        {
            //Get hash code for the Name field if it is not null. 
            int hashProductTestName = name == null ? 0 : name.GetHashCode();

            //Get hash code for the Code field. 
            int hashProductClassName = className.GetHashCode();

            //Calculate the hash code for the product. 
            return hashProductTestName ^ hashProductClassName;
        }
    }

    sealed class Cases
    {
        public List<Case> cases { get; set; } 
    }

    sealed class Run
    {
        public double duration { get; set; }

        public int failCount { get; set; }

        public int passCount { get; set; }

        public int skipCount { get; set; }

        public List<Cases> suites { get; set; } 

        public List<Case> getAllCases()
        {
            var allCases = new List<Case>();

            foreach(Cases c in suites)
            {
                allCases.AddRange(c.cases);
            }
            return allCases;
        }
 

    }
}
